package com.freshcity.upload
{
	import com.freshcity.upload.ui.RectBox;
	
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class AvatarArea extends Sprite
	{
		public function AvatarArea()
		{
			this._labelTxt = "您上传的头像会自动生成三种尺寸，请注意中小尺寸的头像是否清晰";
			super();
			this.init();
			return;
		}
		
		private function init():void
		{
			this.initBoxs();
			this.initTxt();
			return;
		}
		
		private function initBoxs():void
		{
			this._bigBox = this.setBoxs(110, 135, 20, 60);
			this._midBox = this.setBoxs(50, 62, 220, 50);
			this._smallBox = this.setBoxs(24, 29, 230, 180);
			this.bigPic = new flash.display.Bitmap();
			this.midPic = new flash.display.Bitmap();
			this.smallPic = new flash.display.Bitmap();
			var loc1:*;
			this.smallPic.y = loc1 = 1;
			this.smallPic.x = loc1 = loc1;
			this.midPic.y = loc1 = loc1;
			this.midPic.x = loc1 = loc1;
			this.bigPic.y = loc1 = loc1;
			this.bigPic.x = loc1;
			addChild(this._bigBox);
			addChild(this._midBox);
			addChild(this._smallBox);
			this._bigBox.addChild(this.bigPic);
			this._midBox.addChild(this.midPic);
			this._smallBox.addChild(this.smallPic);
			return;
		}
		
		private function setBoxs(arg1:Number, arg2:Number, arg3:Number, arg4:Number):RectBox
		{
			var loc1:* = new RectBox(arg1, arg2);
			loc1.x = arg3;
			loc1.y = arg4;
			return loc1;
		}
		
		private function initTxt():void
		{
			var loc1:*=new flash.text.TextFormat("宋体", 12, 13460736);
			loc1.leading = 4;
			this._label = new flash.text.TextField();
			this._label.multiline = true;
			this._label.wordWrap = true;
			this._label.selectable = false;
			this._label.width = 200;
			this._label.x = 20;
			this._label.y = 6;
			this._label.text = this._labelTxt;
			this._label.setTextFormat(loc1);
			var loc2:*=new flash.text.TextFormat("宋体", 12, 10132122);
			loc2.align = flash.text.TextFormatAlign.CENTER;
			this._bigTxt = this.setText(181, 0, 200, "大尺寸头像，110×135像素", loc2);
			this._midTxt = this.setText(66, 214, 115, "中尺寸头像\n50×62像素(自动生成)", loc2);
			this._smalltxt = this.setText(66, 214, 215, "小尺寸头像\n24×29像素(自动生成)", loc2);
			
			var loc3:*=new flash.text.TextFormat("宋体", 12, 0xff0000);
			loc3.leading = 4;
			loc3.align = flash.text.TextFormatAlign.LEFT;
			this._tipTxt = this.setText(300, 0, 280, "注:头像一旦上传不能修改。虚假或模糊的头像照会影响信誉度，造成严重后果。请谨慎上传。", loc3);
			addChild(this._label);
			addChild(this._bigTxt);
			addChild(this._midTxt);
			addChild(this._smalltxt);
			addChild(this._tipTxt);
			
			return;
		}
		
		private function setText(width:Number, x:Number, y:Number, arg4:String, arg5:flash.text.TextFormat):TextField
		{
			if (width == 66) 
			{
				arg5.leading = 4;
			}
			var loc1:*;
			(loc1 = new TextField()).selectable = false;
			loc1.mouseEnabled = false;
			loc1.width = width;
			loc1.multiline = true;
			loc1.wordWrap = true;
			loc1.x = x;
			loc1.y = y;
			loc1.text = arg4;
			loc1.setTextFormat(arg5);
			return loc1;
		}
		
		public function initAvatars(arg1:flash.display.BitmapData=null):void
		{
			var loc1:*;
			this.smallPic.bitmapData = loc1 = arg1;
			this.midPic.bitmapData = loc1 = loc1;
			this.bigPic.bitmapData = loc1;
			this.setAvatarSize(this.bigPic, 110);
			this.setAvatarSize(this.midPic, 50);
			this.setAvatarSize(this.smallPic, 24);
			return;
		}
		
		public function changeAvatars(arg1:flash.display.BitmapData):void
		{
			var loc1:*;
			this.bigPic.bitmapData = loc1 = null;
			this.midPic.bitmapData = loc1 = loc1;
			this.smallPic.bitmapData = loc1;
			this.bigPic.bitmapData = loc1 = arg1;
			this.midPic.bitmapData = loc1 = loc1;
			this.smallPic.bitmapData = loc1;
			this.setAvatarSize(this.bigPic, 110);
			this.setAvatarSize(this.midPic, 50);
			this.setAvatarSize(this.smallPic, 24);
			return;
		}
		
		private function setAvatarSize(arg1:flash.display.Bitmap, arg2:Number):void
		{
			arg1.width = arg2;
			arg1.scaleY = arg1.scaleX;
			arg1.smoothing = true;
			return;
		}
		
		private var _bigBox:RectBox;
		
		private var _midBox:RectBox;
		
		private var _smallBox:RectBox;
		
		private var _bigTxt:TextField;
		
		private var _midTxt:TextField;
		
		private var _smalltxt:TextField;
		
		private var _tipTxt:TextField;
		
		private var _label:TextField;
		
		private var _labelTxt:String;
		
		public var bigPic:flash.display.Bitmap;
		
		public var midPic:flash.display.Bitmap;
		
		public var smallPic:flash.display.Bitmap;
		
	}
}